using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;
using System.Data;
using System.Data.OleDb;
using DTO;

namespace DAO
{
    public class CDangNhapDao
    {
        public string DangNhapAdmin(string m_sTen, string m_sMatKhau)
        {
            OleDbConnection m_OleDb = DataProvider.ConnectionData();
            DataTable m_DT = new DataTable();

            string m_sSQL = "Select TenDangNhap From NguoiQuanLy Where TenDangNhap = ? and MatKhau = ? ";
            OleDbCommand m_OleDbcmd = new OleDbCommand(m_sSQL, m_OleDb);

            m_OleDbcmd.Parameters.Add("TenDangNhap", OleDbType.LongVarChar);
            m_OleDbcmd.Parameters.Add("MatKhau", OleDbType.LongVarChar);

            m_OleDbcmd.Parameters["TenDangNhap"].Value = m_sTen;
            m_OleDbcmd.Parameters["MatKhau"].Value = m_sMatKhau;

            string m_sTenReturn = (string)m_OleDbcmd.ExecuteScalar();
            
            
            
            return m_sTenReturn;
        }
        public string DangNhap(string m_sTen, string m_sMatKhau)
        {
            OleDbConnection m_OleDb = DataProvider.ConnectionData();
            DataTable m_DT = new DataTable();

            
            string m_sSQL = "Select TenDangNhap From KhachHang Where TenDangNhap = ? and MatKhau = ? ";
            OleDbCommand m_OleDbcmd2 = new OleDbCommand(m_sSQL, m_OleDb);

            m_OleDbcmd2.Parameters.Add("TenDangNhap", OleDbType.LongVarChar);
            m_OleDbcmd2.Parameters.Add("MatKhau", OleDbType.LongVarChar);

            m_OleDbcmd2.Parameters["TenDangNhap"].Value = m_sTen;
            m_OleDbcmd2.Parameters["MatKhau"].Value = m_sMatKhau;
            
            string m_sTenReturn = (string)m_OleDbcmd2.ExecuteScalar();

            return m_sTenReturn;
        }
        public string LayTenDangNhapAdmin(string m_sTen)
        {
            OleDbConnection m_OleDb = DataProvider.ConnectionData();
            DataTable m_DT = new DataTable();

            string m_sSQL = "Select TenDangNhap From NguoiQuanLy Where TenDangNhap = ? ";
            OleDbCommand m_OleDbcmd = new OleDbCommand(m_sSQL, m_OleDb);

            m_OleDbcmd.Parameters.Add("TenDangNhap", OleDbType.LongVarChar);
           

            m_OleDbcmd.Parameters["TenDangNhap"].Value = m_sTen;
           

            string m_sTenReturn = (string)m_OleDbcmd.ExecuteScalar();



            return m_sTenReturn;
        }
        public string LayTenDangNhap(string m_sTen)
        {
            OleDbConnection m_OleDb = DataProvider.ConnectionData();
            DataTable m_DT = new DataTable();


            string m_sSQL = "Select TenDangNhap From KhachHang Where TenDangNhap = ? ";
            OleDbCommand m_OleDbcmd2 = new OleDbCommand(m_sSQL, m_OleDb);

            m_OleDbcmd2.Parameters.Add("TenDangNhap", OleDbType.LongVarChar);
            

            m_OleDbcmd2.Parameters["TenDangNhap"].Value = m_sTen;
           

            string m_sTenReturn = (string)m_OleDbcmd2.ExecuteScalar();

            return m_sTenReturn;
        }
    }
}
